package com.xnx3.banmahuishou.superadmin.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.xnx3.j2ee.util.ActionLogUtil;
import com.xnx3.j2ee.util.AttachmentUtil;
import com.xnx3.j2ee.vo.UploadFileVO;

/**
 * 后台里面公共的一些方法，比如上传图片等
 * @author 王晓龙
 */
@Controller(value="AdminCommonController")
@RequestMapping("/admin/common/")
public class CommonController extends BaseController {
	/**
	 * 图片上传
	 * @author 王晓龙
	 */
	@RequestMapping(value="uploadImage.json", method= {RequestMethod.POST})
	@ResponseBody
	public UploadFileVO uploadImage(HttpServletRequest request, @RequestParam("file") MultipartFile multipartFile){
		//将图片上传到 file/images/ 路径下
		UploadFileVO vo = AttachmentUtil.uploadFile("file/images/", multipartFile); 
		ActionLogUtil.insert(request, "上传图片", vo.toString()); //记录日志
		return vo;
	}
	
	
	
	/**
	 * 总管理后台--首页
	 */
	@RequestMapping("goIndex${url.suffix}")
	public String goIndex(HttpServletRequest request){
		return "/superadmin/index/index";
	}

}
